1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.ViewSwitcherTitle;
26 
27 private import adw.ViewStack;
28 private import adw.c.functions;
29 public  import adw.c.types;
30 private import glib.ConstructionException;
31 private import glib.Str;
32 private import glib.c.functions;
33 private import gobject.ObjectG;
34 private import gtk.AccessibleIF;
35 private import gtk.AccessibleT;
36 private import gtk.BuildableIF;
37 private import gtk.BuildableT;
38 private import gtk.ConstraintTargetIF;
39 private import gtk.ConstraintTargetT;
40 private import gtk.Widget;
41 
42 
43 /**
44  * A view switcher title.
45  * 
46  * <picture>
47  * <source srcset="view-switcher-title-dark.png" media="(prefers-color-scheme: dark)">
48  * <img src="view-switcher-title.png" alt="view-switcher-title">
49  * </picture>
50  * 
51  * A widget letting you switch between multiple views contained by a
52  * [class@ViewStack] via an [class@ViewSwitcher].
53  * 
54  * It is designed to be used as the title widget of a [class@HeaderBar], and
55  * will display the window's title when the window is too narrow to fit the view
56  * switcher e.g. on mobile phones, or if there are less than two views.
57  * 
58  * In order to center the title in narrow windows, the header bar should have
59  * [property@HeaderBar:centering-policy] set to
60  * `ADW_CENTERING_POLICY_STRICT`.
61  * 
62  * `AdwViewSwitcherTitle` is intended to be used together with
63  * [class@ViewSwitcherBar].
64  * 
65  * A common use case is to bind the [property@ViewSwitcherBar:reveal] property
66  * to [property@ViewSwitcherTitle:title-visible] to automatically reveal the
67  * view switcher bar when the title label is displayed in place of the view
68  * switcher, as follows:
69  * 
70  * ```xml
71  * <object class="GtkWindow">
72  * <child type="titlebar">
73  * <object class="AdwHeaderBar">
74  * <property name="centering-policy">strict</property>
75  * <child type="title">
76  * <object class="AdwViewSwitcherTitle" id="title">
77  * <property name="stack">stack</property>
78  * </object>
79  * </child>
80  * </object>
81  * </child>
82  * <child>
83  * <object class="GtkBox">
84  * <property name="orientation">vertical</property>
85  * <child>
86  * <object class="AdwViewStack" id="stack"/>
87  * </child>
88  * <child>
89  * <object class="AdwViewSwitcherBar">
90  * <property name="stack">stack</property>
91  * <binding name="reveal">
92  * <lookup name="title-visible">title</lookup>
93  * </binding>
94  * </object>
95  * </child>
96  * </object>
97  * </child>
98  * </object>
99  * ```
100  * 
101  * ## CSS nodes
102  * 
103  * `AdwViewSwitcherTitle` has a single CSS node with name `viewswitchertitle`.
104  *
105  * Since: 1.0
106  */
107 public class ViewSwitcherTitle : Widget
108 {
109 	/** the main Gtk struct */
110 	protected AdwViewSwitcherTitle* adwViewSwitcherTitle;
111 
112 	/** Get the main Gtk struct */
113 	public AdwViewSwitcherTitle* getViewSwitcherTitleStruct(bool transferOwnership = false)
114 	{
115 		if (transferOwnership)
116 			ownedRef = false;
117 		return adwViewSwitcherTitle;
118 	}
119 
120 	/** the main Gtk struct as a void* */
121 	protected override void* getStruct()
122 	{
123 		return cast(void*)adwViewSwitcherTitle;
124 	}
125 
126 	/**
127 	 * Sets our main struct and passes it to the parent class.
128 	 */
129 	public this (AdwViewSwitcherTitle* adwViewSwitcherTitle, bool ownedRef = false)
130 	{
131 		this.adwViewSwitcherTitle = adwViewSwitcherTitle;
132 		super(cast(GtkWidget*)adwViewSwitcherTitle, ownedRef);
133 	}
134 
135 
136 	/** */
137 	public static GType getType()
138 	{
139 		return adw_view_switcher_title_get_type();
140 	}
141 
142 	/**
143 	 * Creates a new `AdwViewSwitcherTitle`.
144 	 *
145 	 * Returns: the newly created `AdwViewSwitcherTitle`
146 	 *
147 	 * Since: 1.0
148 	 *
149 	 * Throws: ConstructionException GTK+ fails to create the object.
150 	 */
151 	public this()
152 	{
153 		auto __p = adw_view_switcher_title_new();
154 
155 		if(__p is null)
156 		{
157 			throw new ConstructionException("null returned by new");
158 		}
159 
160 		this(cast(AdwViewSwitcherTitle*) __p);
161 	}
162 
163 	/**
164 	 * Gets the stack controlled by @self.
165 	 *
166 	 * Returns: the stack
167 	 *
168 	 * Since: 1.0
169 	 */
170 	public ViewStack getStack()
171 	{
172 		auto __p = adw_view_switcher_title_get_stack(adwViewSwitcherTitle);
173 
174 		if(__p is null)
175 		{
176 			return null;
177 		}
178 
179 		return ObjectG.getDObject!(ViewStack)(cast(AdwViewStack*) __p);
180 	}
181 
182 	/**
183 	 * Gets the subtitle of @self.
184 	 *
185 	 * Returns: the subtitle
186 	 *
187 	 * Since: 1.0
188 	 */
189 	public string getSubtitle()
190 	{
191 		return Str.toString(adw_view_switcher_title_get_subtitle(adwViewSwitcherTitle));
192 	}
193 
194 	/**
195 	 * Gets the title of @self.
196 	 *
197 	 * Returns: the title
198 	 *
199 	 * Since: 1.0
200 	 */
201 	public string getTitle()
202 	{
203 		return Str.toString(adw_view_switcher_title_get_title(adwViewSwitcherTitle));
204 	}
205 
206 	/**
207 	 * Gets whether the title of @self is currently visible.
208 	 *
209 	 * Returns: whether the title of @self is currently visible
210 	 *
211 	 * Since: 1.0
212 	 */
213 	public bool getTitleVisible()
214 	{
215 		return adw_view_switcher_title_get_title_visible(adwViewSwitcherTitle) != 0;
216 	}
217 
218 	/**
219 	 * Gets whether @self's view switcher is enabled.
220 	 *
221 	 * Returns: whether the view switcher is enabled
222 	 *
223 	 * Since: 1.0
224 	 */
225 	public bool getViewSwitcherEnabled()
226 	{
227 		return adw_view_switcher_title_get_view_switcher_enabled(adwViewSwitcherTitle) != 0;
228 	}
229 
230 	/**
231 	 * Sets the stack controlled by @self.
232 	 *
233 	 * Params:
234 	 *     stack = a stack
235 	 *
236 	 * Since: 1.0
237 	 */
238 	public void setStack(ViewStack stack)
239 	{
240 		adw_view_switcher_title_set_stack(adwViewSwitcherTitle, (stack is null) ? null : stack.getViewStackStruct());
241 	}
242 
243 	/**
244 	 * Sets the subtitle of @self.
245 	 *
246 	 * Params:
247 	 *     subtitle = a subtitle
248 	 *
249 	 * Since: 1.0
250 	 */
251 	public void setSubtitle(string subtitle)
252 	{
253 		adw_view_switcher_title_set_subtitle(adwViewSwitcherTitle, Str.toStringz(subtitle));
254 	}
255 
256 	/**
257 	 * Sets the title of @self.
258 	 *
259 	 * Params:
260 	 *     title = a title
261 	 *
262 	 * Since: 1.0
263 	 */
264 	public void setTitle(string title)
265 	{
266 		adw_view_switcher_title_set_title(adwViewSwitcherTitle, Str.toStringz(title));
267 	}
268 
269 	/**
270 	 * Sets whether @self's view switcher is enabled.
271 	 *
272 	 * Params:
273 	 *     enabled = whether the view switcher is enabled
274 	 *
275 	 * Since: 1.0
276 	 */
277 	public void setViewSwitcherEnabled(bool enabled)
278 	{
279 		adw_view_switcher_title_set_view_switcher_enabled(adwViewSwitcherTitle, enabled);
280 	}
281 }